//
//  TKTopicViewController.m
//  装修管家
//
//  Created by 千锋 on 16/1/21.
//  Copyright (c) 2016年 IOS1503薛凯. All rights reserved.
//

#import "TKTopicViewController.h"
#import "TKRootViewController.h"
#import "TKSingleViewController.h"
@interface TKTopicViewController ()
@property (weak, nonatomic) IBOutlet UISegmentedControl *segment;

@end

@implementation TKTopicViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
       self.segment.selectedSegmentIndex=2;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor cyanColor];

    // Do any additional setup after loading the view from its nib.
}

- (IBAction)segmenChange:(UISegmentedControl *)sender {
    switch (sender.selectedSegmentIndex) {
        case 0:
        {
            int num=0;
            for (UIViewController* view in self.navigationController.viewControllers) {
                if ([view isKindOfClass:[TKRootViewController class]]) {
                    [self.navigationController popToViewController:view animated:NO];
                    
                    num=1;
                }
            }
            if (num==0) {
                TKRootViewController* root=[[TKRootViewController alloc] init];
                [self.navigationController pushViewController:root animated:NO];
            }
            break;
        }
        case 1:{
            int num=0;
            for (UIViewController* view in self.navigationController.viewControllers) {
                if ([view isKindOfClass:[TKSingleViewController class]]) {
                    [self.navigationController popToViewController:view animated:NO];
                    
                    num=1;
                }
            }
            if (num==0) {
                TKSingleViewController* single=[[TKSingleViewController alloc] init];
                [self.navigationController pushViewController:single animated:NO];
            }
            break;
        }
        default:
            break;
    }
}


@end
